import axios from 'axios'
import store from "@/store/index"
import JSONbig from "json-bigint"

const request = axios.create({
    baseURL:'http://ttapi.research.itcast.cn/app/',
    transformResponse:[function (data){
        try{
            return JSONbig.parse(data)
        }catch(err){
            // console
            return data
        }
    }]
})
// 请求拦截器
request.interceptors.request.use(function(config){
    const { user } = store.state
    
    if (user) {
        config.headers.Authorization = `Bearer ${user.token}`
    }
    return config

})
export default request


